import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Seperate startup class for people that want to run the examples directly.
 */
public class StartJettyMdp
{
	private static final Logger	LOG	= LoggerFactory.getLogger( StartJettyMdp.class );
	
	/**
	 * Main function, starts the jetty server.
	 * 
	 * @param args
	 */
	public static void main( String[] args )
	{
		StartJettyMdp.LOG.debug( "Starting jetty" );
		final Server server = new Server();
		final SelectChannelConnector connector = new SelectChannelConnector();
		connector.setPort( 8080 );
		server.setConnectors( new Connector[]
		{ connector } );
		
		final WebAppContext web = new WebAppContext();
		web.setContextPath( "/mdp" );
		web.setWar( "../mdp-ui/war" );
		server.addHandler( web );
		
		try
		{
			server.start();
			server.join();
		}
		catch( final Exception e )
		{
			e.printStackTrace();
			System.exit( 100 );
		}
		
	}
}
